#.PHONY: clean rm rmall rmt

###########################
# environment definitions
###########################

include $(PROJECT_BASE)/zsystem/make/os.mk

ifeq ($(USE_TCMALLOC), on)
ifneq ($(release),)
  PROGLIBS += -ltcmalloc_minimal
else
  PROGLIBS += -ltcmalloc_and_profiler
endif
  PROGDEFS += -DUSE_TCMALLOC
endif

CFLAGS = -D_REENTRANT -m64
LINKCMDENDOFLINE =  

ifeq ($(rough),on)
 WARNING += -isystem /sw/tools/include-v2 -fno-builtin -fsigned-char -ansi -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wpedantic
endif

srcdir   = .
os       = $(OS)
root_dir = ${PROJECT_BASE}

# assigning different dirs for different compilation options
conf_dir =

ifeq ($(ipv6),on)
  conf_dir := ${conf_dir}Ipv6
endif

ifeq ($(release),on)
  conf_dir := ${conf_dir}Release
else
  conf_dir := ${conf_dir}Debug
endif

ifeq ($(nolog),on)
  conf_dir := ${conf_dir}NoLog
endif

conf_dir := ${conf_dir}/

bindir    = ${root_dir}/zsystem/${os}/${conf_dir}bin
libdir    = ${root_dir}/zsystem/${os}/${conf_dir}lib
libsubdir = ${root_dir}/zsystem/${os}/${conf_dir}lib/.sublib
objdir    = ${root_dir}/zsystem/${os}/${conf_dir}obj
incdir    = ${root_dir}
mkdir     = ${root_dir}/zsystem/make

INSTALL = /bin/install -c
INSTALL_PROGRAM = ${INSTALL}
RM      = rm
COPY 	= cp
AR      = ar
ARFLAGS = crv
RANLIB  = ranlib

ifneq ($(OS),Windows_NT)
SHELL   = /bin/sh
endif

PROFILE = 

CPPFLAGS = -I/usr/local/include -I${OPENSOURCE_INC}
DEFS    =

CC      = gcc
CPP     = g++
OPTIMI  = -O2

LD      = $(CPP)


LINT    = lint

ifeq ($(nolog),on)
CFLAGS += -D__NOLOG__
endif

ifeq ($(ipv6),on)
CFLAGS += -D__IPV6__
endif

ifeq ($(profile),on)
PROFILE = -pg
else
PROFILE = 
endif

######################
## Switching between machines.
######################
ifeq ($(os),Linux)
  CFLAGS += -D__KERNEL_POSIX__ -D__LINUX__ -D__AMD64__
  LINKCMD += -Xlinker -rpath /usr/local/lib 
  LINKCMD += -lresolv
endif

######################
## HP
######################
HPUX_CFLAGS   = -Aa -D_HPUX_SOURCE -D_POSIX_SOURCE -DXOPEN_CATALOG +e
LINT_FLAGS    = -Aa -s

ifeq ($(os),Linux)
	DEFS   += -D__LINUX__ -I/usr/include/ncurses
	RM = rm
endif

ifneq ($(release),)
  CFLAGS  +=  $(OPTIMI) $(WARNING) $(PROFILE) -D__RELEASE__
else
  CFLAGS  += -g $(WARNING) $(PROFILE) -D__DEBUG__
endif

